package com.qiang.test03;

import java.io.*;

public class Demo02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //序列化，将对象保存到磁盘中，或者在网络中传输
        //ObjectOutputStream

        ObjectOutputStream oo = new ObjectOutputStream(new FileOutputStream("day12\\aa.txt"));
        Student s = new Student("张三", 22);

        oo.writeObject(s);
        oo.close();

        ObjectInputStream oi = new ObjectInputStream(new FileInputStream("day12\\aa.txt"));
        Object o = oi.readObject();
        Student student = (Student) o;
        oi.close();
        System.out.println(student);
    }
}
